﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace Utility.Data.DbClient
{
    /// <summary>
    /// DB参数
    /// </summary>
    public class DBParameter 
    {
        // Fields
        internal ParameterDirection _direction;
        /// <summary>
        /// 
        /// </summary>
        public DBParameter()
        { }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterName">参数名</param>
        public DBParameter(string parameterName)
        {
            this.ParameterName = parameterName;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterName">参数名</param>
        /// <param name="value">值</param>
        public DBParameter(string parameterName, object value)
        {
            this.ParameterName = parameterName;
            this.Value = value;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterName">参数名</param>
        /// <param name="type">参数类型</param>
        public DBParameter(string parameterName, DBType type)
        {
            this.ParameterName = parameterName;
            this.DbType = type;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterName">参数名</param>
        /// <param name="type">参数类型</param>
        public DBParameter(string parameterName, DBType type, int size)
        {
            this.ParameterName = parameterName;
            this.DbType = type;
            this.Size = size;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterName">参数名</param>
        /// <param name="type">参数类型</param>
        /// <param name="direction">参数的类型:输入参数,输出参数,输入输出参数,参数表示诸如存储过程、内置函数或用户定义函数之类的操作的返回值。</param>
        public DBParameter(string parameterName, DBType type, ParameterDirection direction)
        {
            this.ParameterName = parameterName;
            this.DbType = type;
            this.Direction = direction;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parameterName">参数名</param>
        /// <param name="type">参数类型</param>
        /// <param name="value">值</param>
        /// <param name="direction">参数的类型:输入参数,输出参数,输入输出参数,参数表示诸如存储过程、内置函数或用户定义函数之类的操作的返回值。</param>
        public DBParameter(string parameterName, DBType type, object value, ParameterDirection direction)
        {
            this.ParameterName = parameterName;
            this.DbType = type;
            this.Value = value;
            this.Direction = direction;
        }
        public DBParameter(string parameterName, DBType type, int size, object value, ParameterDirection direction)
        {
            this.ParameterName = parameterName;
            this.DbType = type;
            this.Value = value;
            this.Direction = direction;
            this.Size = size;
        }
        private DBType? _DbType = null;
        /// <summary>
        /// 参数类型,默认DbType.String
        /// </summary>
        public DBType? DbType
        {
            get { return _DbType; }
            set { _DbType = value; }
        }
        public int? Size
        {
            get; set;
        }
        /// <summary>
        /// 参数名
        /// </summary>
        public string ParameterName
        {
            get; set;
        }
        /// <summary>
        /// 参数的类型:输入参数,输出参数,输入输出参数,参数表示诸如存储过程、内置函数或用户定义函数之类的操作的返回值。
        /// </summary>
        public ParameterDirection Direction
        {
            get
            {
                ParameterDirection direction = this._direction;
                if (direction == ((ParameterDirection)0))
                {
                    return ParameterDirection.Input;
                }
                return direction;
            }
            set
            {
                if (this._direction != value)
                {
                    switch (value)
                    {
                        case ParameterDirection.Input:
                        case ParameterDirection.Output:
                        case ParameterDirection.InputOutput:
                        case ParameterDirection.ReturnValue:
                            this._direction = value;
                            return;
                    }
                }
            }
        }
        /// <summary>
        /// 值
        /// </summary>
        public object Value
        {
            get; set;
        }
    }
    
}
